// ignore_for_file: prefer_const_constructors

import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:time_manager/view/add_record/add_record_controller.dart';

class AddRecordView extends StatelessWidget {
  AddRecordView({Key? key}) : super(key: key);
  final controller = Get.put(AddRecordController());
  //时间  日程描述  时长

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        resizeToAvoidBottomInset: true,
        appBar: AppBar(
          title: const Text('添加日程'),
        ),
        bottomSheet: ElevatedButton(
            style: ElevatedButton.styleFrom(
              minimumSize: Size(double.infinity, 50),
              shape: RoundedRectangleBorder(
                borderRadius: BorderRadius.circular(0),
              ),
            ),
            onPressed: () {
              controller.confirm();
            },
            child: Text('提交')),
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            children: [
              Container(
                margin: EdgeInsets.all(10),
                child: Text(
                  '默然创建的是明天日程，可以点击修改时间',
                  style: TextStyle(color: Colors.orange, fontSize: 13),
                ),
              ),
              Container(
                padding: EdgeInsets.only(top: 16, bottom: 16),
                decoration: BoxDecoration(
                    border: Border(
                        bottom:
                            BorderSide(color: Color(0xffeeeeee), width: 1))),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('时间'),
                    InkWell(
                        onTap: () {
                          controller.showDate();
                        },
                        // ignore: prefer_const_literals_to_create_immutables
                        child: Row(children: [
                          Obx(() => Text(controller.time.value)),
                          Icon(Icons.arrow_right_outlined)
                        ]))
                  ],
                ),
              ),
              Container(
                padding: EdgeInsets.only(top: 16, bottom: 16),
                decoration: BoxDecoration(
                    border: Border(
                        bottom:
                            BorderSide(color: Color(0xffeeeeee), width: 1))),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('日程'),
                    SizedBox(
                      width: 100,
                    ),
                    Expanded(
                        child: TextField(
                      onChanged: (val) {
                        print(val);
                      },
                      maxLines: 3,
                      minLines: 1,
                      textAlign: TextAlign.right,
                      decoration: null,
                      controller: controller.titleController,
                    ))
                  ],
                ),
              ),
              Container(
                padding: EdgeInsets.only(top: 16, bottom: 16),
                decoration: BoxDecoration(
                    border: Border(
                        bottom:
                            BorderSide(color: Color(0xffeeeeee), width: 1))),
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text('时长'),
                    SizedBox(
                      width: 100,
                    ),
                    Expanded(
                        child: Row(
                      children: [
                        Expanded(
                            child: TextField(
                          focusNode: controller.commentFocus,
                          keyboardType: TextInputType.number,
                          textAlign: TextAlign.right,
                          decoration: null,
                          controller: controller.durationController,
                        )),
                        SizedBox(
                          width: 10,
                        ),
                        Text('小时')
                      ],
                    ))
                  ],
                ),
              ),
            ],
          ),
        ));
  }
}
